namespace Daemon.Model.ViewModel
{
    public class ImportRowResult
    {
        private ImportRowResult()
        {
        }

        public ImportRowResultType Type { get; set; }

        public int Count { get; private set; } = 1;

        public object DbEntityKeyValue { get; private set; }

        public static ImportRowResult CreateFailedResult(int count = 1)
        {
            return new ImportRowResult { DbEntityKeyValue = null, Count = count, Type = ImportRowResultType.Failed };
        }

        public static ImportRowResult CreateUpdatedResult(int count = 1)
        {
            return CreateUpdatedResult(null, count);
        }

        public static ImportRowResult CreateUpdatedResult(object entityKeyValue, int count = 1)
        {
            return new ImportRowResult { DbEntityKeyValue = entityKeyValue, Count = count, Type = ImportRowResultType.Updated };
        }

        public static ImportRowResult CreateInsertedResult(int count = 1)
        {
            return CreateInsertedResult(null, count);
        }

        public static ImportRowResult CreateInsertedResult(object entityKeyValue, int count = 1)
        {
            return new ImportRowResult { DbEntityKeyValue = entityKeyValue, Count = count, Type = ImportRowResultType.Inserted };
        }

        public static ImportRowResult CreateSkippedResult(object entityKeyValue, int count = 1)
        {
            return new ImportRowResult { DbEntityKeyValue = entityKeyValue, Count = count, Type = ImportRowResultType.Skipped };
        }

        public static ImportRowResult CreateSkippedResult(int count = 1)
        {
            return CreateSkippedResult(null, count);
        }
    }
}